// import user from "../../../utils/user";
const app = getApp()
Page({
    data: {},
    onLoad: function () {
        const ctx = wx.createCanvasContext('myCanvas')
        ctx.rect(0, 0, 350, 450)
        ctx.setFillStyle('#fff')
        ctx.fill()
        ctx.clip() // 剪切
        // 居中
        ctx.textAlign = 'center'
        ctx.setFillStyle('#141F33')
        ctx.setFontSize(16)
        ctx.fillText('扫码注册后点击“我的工资单”', 175, 48)
        ctx.fillText('查看详情', 175, 78)
        ctx.setFillStyle('#90959F')
        ctx.setFontSize(14)
        ctx.fillText('长按图片扫码添加', 175, 310)
        // 二维码放置
        ctx.drawImage('/packagePay/assets/img/payroll-poster/c-qrcode.jpg', 95, 115, 160, 160, 0, 0)
        ctx.draw(true)
    },
    savecanvas() {
        wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 350,
            height: 450,
            canvasId: 'myCanvas',
            success: function(res) {
                console.log(res)
                let img = res.tempFilePath
                wx.saveImageToPhotosAlbum({
                    filePath: img,
                    success() {
                        app.toast('成功保存', 'success')
                    },
                    fail(err) {
                        app.toast('保存失败', err)
                    }
                })
                console.log(res.tempFilePath)
            },
            fail(err) {
                console.log(err)
            }
        })
    },
})